
import java.io.File;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

import com.thoughtworks.selenium.Selenium;

public class Test  {
	static Selenium selenium;
	static WebDriver driver=null;
    public static void main(String[] args) {
    	//try{
       setDriver();

    	// A "base url", used by selenium to resolve relative URLs
    	 String baseUrl = "";
    	// Create the Selenium implementation
     	selenium = new WebDriverBackedSelenium(driver, baseUrl);
     	Aken ak=new Aken(selenium);
    	/*}
    	catch(Exception e){
    		System.out.println(e);
    		System.exit(0);
    	}*/
    }
    
    static void setDriver(){//Brauseri driveri valik
    	Object[] possibilities = {"Firefox", "IE", "Chrome", "Ilma brauserita"};
    	JFrame frame=new JFrame();
    	ImageIcon icon=new ImageIcon();
    	String s = (String)JOptionPane.showInputDialog(
    	                    frame,
    	                    "Mis brauserit kasutada?",
    	                    "Veebisirvija valik",
    	                    JOptionPane.PLAIN_MESSAGE,
    	                    icon,
    	                    possibilities,
    	                    "Firefox");

    	if ((s != null) && (s.length() > 0)) {
    		if (s.compareTo("Firefox")==0){
    			FirefoxProfile profile = new FirefoxProfile();
    			driver = new FirefoxDriver(profile);
    		}
    		if(s.compareTo("IE")==0) driver = new InternetExplorerDriver();
    		if(s.compareTo("Ilma brauserita")==0) driver=new HtmlUnitDriver();
    		if(s.compareTo("Chrome")==0) {
    			ChromeDriverService service=new ChromeDriverService.Builder()
    			.usingChromeDriverExecutable(new File("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"))
    			.build();
    			driver=new ChromeDriver(service);
    		}
    	}
    	return;
    }
    
  

    
}